﻿using SqlSugar;
using System.Collections.Generic;

namespace Acme.BookStore.Navigates
{
    [SugarTable("Student")]
    public class Student
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int StudentId { get; set; }

        public string Name { get; set; }
        public int SchoolId { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(SchoolId))]//一对一
        public School School { get; set; }

        [Navigate(NavigateType.OneToMany, nameof(StuBook.StudentId))]//一对多
        public List<StuBook> Books { get; set; }
    }

    [SugarTable("School")]
    public class School
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int SchoolId { get; set; }

        public string SchoolName { get; set; }

        [Navigate(NavigateType.OneToMany, nameof(Room.SchoolId))]//一对多
        public List<Room> RoomList { get; set; }

        [SugarColumn(IsIgnore = true)]
        public List<Teacher> TeacherList { get; set; }
    }

    [SugarTable("Room")]
    public class Room
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int RoomId { get; set; }

        public string RoomName { get; set; }
        public int SchoolId { get; set; }
    }

    [SugarTable("Teacher")]
    public class Teacher
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int Id { get; set; }

        public int SchoolId { get; set; }
        public string Name { get; set; }
    }

    [SugarTable("Book")]
    public class StuBook
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int BookId { get; set; }

        public string Name { get; set; }

        [SugarColumn(IsPrimaryKey = true)]
        public int StudentId { get; set; }
    }
}